/* GUI CONVERTED from sqqorp.p (converter v1.76) Wed Jul 10 23:13:53 2002 */
/* sqqorp.p - QUOTE REPORT BY QUOTE NUMBER                                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.15 $                                                          */
/*V8:ConvertMode=FullGUIReport                                                */
/* REVISION: 4.0      LAST MODIFIED: 12/12/88   BY: jms *A548*                */
/* REVISION: 5.0      LAST MODIFIED: 03/09/89   BY: jms *B064*                */
/* REVISION: 5.0      LAST MODIFIED: 03/21/89   BY: RL  *B051*                */
/* REVISION: 6.0      LAST MODIFIED: 04/20/90   BY: ftb *                     */
/* REVISION: 6.0      LAST MODIFIED: 03/27/91   BY: bjb *D461*                */
/* REVISION: 6.0      LAST MODIFIED: 04/17/91   BY: bjb *D515*                */
/* REVISION: 7.0      LAST MODIFIED: 03/17/92   BY: TMD *F264*                */
/* REVISION: 7.0      LAST MODIFIED: 03/27/92   BY: dld *F326*                */
/* REVISION: 7.0      LAST MODIFIED: 06/08/92   BY: afs *F586*                */
/* REVISION: 7.0      LAST MODIFIED: 06/26/92   BY: afs *F709*                */
/* REVISION: 7.3      LAST MODIFIED: 01/13/94   BY: dpm *FL32*                */
/* REVISION: 7.3      LAST MODIFIED: 11/01/94   BY: ame *GN94*                */
/* REVISION: 8.5      LAST MODIFIED: 09/12/95   BY: taf *J053*                */
/* REVISION: 8.5      LAST MODIFIED: 04/09/96   BY: jzw *G1P6*                */
/* REVISION: 8.5      LAST MODIFIED: 07/17/96   BY: taf *J0ZH*                */
/* REVISION: 8.5      LAST MODIFIED: 06/10/97   BY: taf *J0ZH*                */
/* REVISION: 8.6      LAST MODIFIED: 10/08/97   BY: GYK *K0M4*                */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 06/11/98   BY: *L02K* Russ Witt          */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KN* Mark Brown         */
/* REVISION: 9.1      LAST MODIFIED: 10/25/00   BY: *N0T7* Jean Miller        */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.15 $    BY: Hareesh V.            DATE: 06/21/02  ECO: *N1HY*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */

/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "2+ "}

{gpcurrp.i}

define variable rndmthd         like rnd_rnd_mthd                     no-undo.
define variable oldcurr         like qo_curr                          no-undo.
define variable cust            like qo_cust                          no-undo.
define variable cust1           like qo_cust                          no-undo.
define variable nbr             like qo_nbr                           no-undo.
define variable nbr1            like qo_nbr                           no-undo.
define variable ord             like qo_ord_date                      no-undo.
define variable ord1            like qo_ord_date                      no-undo.
define variable slspsn          as   character    format "x(8)"
                                label "Salesperson"                   no-undo.
define variable slspsn1         like slspsn                           no-undo.
define variable name            like ad_name                          no-undo.
define variable base_tot        like qod_price                        no-undo.
define variable base_tot_unrnd  like qod_price                        no-undo.
define variable ext_price       like qod_price    label "Ext Price"
                                format "->>,>>>,>>>,>>9.99<<<<"       no-undo.
define variable ext_price_unrnd like qod_price                        no-undo.
define variable desc1           like pt_desc1     format "x(49)"      no-undo.
define variable expdate         like qo_exp_date                      no-undo.
define variable expdate1        like qo_exp_date                      no-undo.
define variable flwdate         like qo_flw_date                      no-undo.
define variable flwdate1        like qo_flw_date                      no-undo.
define variable cycle           like qo_cycle                         no-undo.
define variable cycle1          like qo_cycle                         no-undo.
define variable release_only    like qo_release
                                label "To Be Released Only"           no-undo.
define variable base_price      like qod_price                        no-undo.
define variable base_rpt        like qo_curr                          no-undo.
define variable mixed_rpt       like mfc_logical  initial no
                                label "Mixed Currencies"              no-undo.
define variable disp_curr       as   character    format "x(1)"
                                label "C"                             no-undo.
define variable plines          as   integer                          no-undo.
define variable curr_price      like qod_price                        no-undo.
define variable mc-error-number like msg_nbr                          no-undo.
define variable o_disp_line1    as character      format "x(40)"      no-undo.
define variable o_disp_line2    as character      format "x(40)"      no-undo.

/* DATA DEFINITIONS FOR TRIANGULATION LIBRARY ROUTINES */
{gprunpdf.i "mcpl" "p"}
{gprunpdf.i "mcui" "p"}


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
nbr          colon 15   nbr1     label "To"     colon 49
   cust         colon 15   cust1    label "To"     colon 49
   slspsn       colon 15   slspsn1  label "To"     colon 49
   ord          colon 15   ord1     label "To"     colon 49
   expdate      colon 15   expdate1 label "To"     colon 49
   flwdate      colon 15   flwdate1 label "To"     colon 49
   cycle        colon 15   cycle1   label "To"     colon 49  skip(1)
   release_only colon 25   base_rpt                colon 25
   mixed_rpt    colon 25
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

find first gl_ctrl no-lock no-error.
oldcurr = "".

{wbrp01.i}

/*GUI*/ {mfguirpa.i true "printer" 132 " " " " " "  }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:


   if can-find(first order_wkfl)
   then
      for each order_wkfl
      exclusive-lock:
         delete order_wkfl.
      end. /* FOR EACH order_wkfl */

   if nbr1     = hi_char  then nbr1     = "".
   if cust1    = hi_char  then cust1    = "".
   if slspsn1  = hi_char  then slspsn1  = "".
   if ord      = low_date then ord      = ?.
   if ord1     = hi_date  then ord1     = ?.
   if expdate  = low_date then expdate  = ?.
   if expdate1 = hi_date  then expdate1 = ?.
   if flwdate  = low_date then flwdate  = ?.
   if flwdate1 = hi_date  then flwdate1 = ?.
   if cycle1   = hi_char  then cycle1   = "".

   if c-application-mode <> 'WEB'
   then
      
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


   {wbrp06.i
      &command = update
      &fields = "  nbr nbr1 cust cust1 slspsn slspsn1 ord ord1
                   expdate expdate1 flwdate flwdate1 cycle cycle1
                   release_only base_rpt mixed_rpt"
      &frm = "a"}

   if     (c-application-mode <> 'WEB')
      or  (c-application-mode = 'WEB'
      and (c-web-request begins 'DATA'))
   then do:

      /* CREATE BATCH INPUT STRING */
      bcdparm = "".
      {mfquoter.i nbr     }
      {mfquoter.i nbr1    }
      {mfquoter.i cust    }
      {mfquoter.i cust1   }
      {mfquoter.i slspsn  }
      {mfquoter.i slspsn1 }
      {mfquoter.i ord     }
      {mfquoter.i ord1    }
      {mfquoter.i expdate }
      {mfquoter.i expdate1}
      {mfquoter.i flwdate }
      {mfquoter.i flwdate1}
      {mfquoter.i cycle   }
      {mfquoter.i cycle1  }
      {mfquoter.i release_only }
      {mfquoter.i base_rpt }
      {mfquoter.i mixed_rpt}

      if nbr1     = "" then nbr1     = hi_char.
      if cust1    = "" then cust1    = hi_char.
      if slspsn1  = "" then slspsn1  = hi_char.
      if ord      = ?  then ord      = low_date.
      if ord1     = ?  then ord1     = hi_date.
      if expdate  = ?  then expdate  = low_date.
      if expdate1 = ?  then expdate1 = hi_date.
      if flwdate  = ?  then flwdate  = low_date.
      if flwdate1 = ?  then flwdate1 = hi_date.
      if cycle1   = "" then cycle1   = hi_char.

   end. /* IF (c-application-mode <> 'WEB') */
   /* OUTPUT DESTINATION SELECTION */
   
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i "printer" 132 " " " " " " " " }
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:
find first gl_ctrl no-lock no-error.


/*fdn*/
    {hksimsg.i """" """"}
/*fdn*/

   {mfphead.i}

   do with frame c width 132:

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame c:handle).

      for each qo_mstr
         fields(qo_curr         qo_cust         qo_cycle        qo_exp_date
                qo_exru_seq     qo_ex_rate      qo_ex_rate2     qo_flw_date
                qo_nbr          qo_ord_date     qo_recur        qo_release
                qo_rel_date     qo_rmks         qo_slspsn       qo_stat
                qo_ship)
         where qo_nbr  >= nbr  and qo_nbr  <= nbr1
         and   qo_cust >= cust and qo_cust <= cust1
         and ((qo_slspsn[1] >= slspsn and qo_slspsn[1] <= slspsn1)
           or (qo_slspsn[2] >= slspsn and qo_slspsn[2] <= slspsn1)
           or (qo_slspsn[3] >= slspsn and qo_slspsn[3] <= slspsn1)
           or (qo_slspsn[4] >= slspsn and qo_slspsn[4] <= slspsn1))
         and qo_ord_date >= ord     and qo_ord_date <= ord1
         and qo_exp_date >= expdate and qo_exp_date <= expdate1
         and ((qo_flw_date >= flwdate and qo_flw_date <= flwdate1)
           or (flwdate1    =  hi_date and qo_flw_date =  ?))
         and qo_cycle     >= cycle and qo_cycle  <= cycle1
         and (base_rpt     = ""    or  qo_curr    = base_rpt)
         and (release_only = no    or  qo_release = yes) AND (LOOKUP(qo_site, GLOBAL_user_site) > 0)    /*fdn*/
      no-lock by qo_nbr with frame c:

         if    (oldcurr <> qo_curr)
            or (oldcurr = "")
         then do:

            if qo_curr = gl_base_curr
            then
               rndmthd = gl_rnd_mthd.
            else do:
               /* GET ROUNDING METHOD FROM CURRENCY MASTER */
               {gprunp.i "mcpl" "p" "mc-get-rnd-mthd"
                  "(input qo_curr,
                    output rndmthd,
                    output mc-error-number)"}
               if mc-error-number <> 0
               then do:
                  {pxmsg.i &MSGNUM=mc-error-number &ERRORLEVEL=4}
                  if c-application-mode <> "WEB"
                  then
                     leave.
                  pause.
               end. /* IF mc-error-number <> 0 */
            end. /* ELSE DO */

            oldcurr = qo_curr.
         end. /* IF (oldcurr <> qo_curr) */

         name = "".
         for first ad_mstr
            fields(ad_addr ad_name)
            where ad_addr = qo_cust
         no-lock:
            name = ad_name.
         end. /* FOR FIRST ad_mstr */

         if qo_curr <> base_curr
         then do on endkey undo, retry:

            {gprunp.i "mcui" "p" "mc-ex-rate-output"
               "(input qo_curr,
                 input base_curr,
                 input qo_ex_rate,
                 input qo_ex_rate2,
                 input qo_exru_seq,
                 output o_disp_line1,
                 output o_disp_line2)"}
         end. /* IF qo_curr <> base_curr */
         else
            assign
               o_disp_line1 = ""
               o_disp_line2 = ""
               plines       = 1.

         if   (o_disp_line1 <> ""
            or qo_slspsn[2] <> "")
         then
            plines = plines + 1.

         if   (o_disp_line2 <> ""
            or qo_slspsn[3] <> "")
         then
            plines = plines + 1.

         if qo_slspsn[4] <> ""
         then
            plines = plines + 1.
         if qo_rmks <> ""
         then
            plines = plines + 1.
         if page-size - line-counter <= plines
         then
            page.

         do with frame b:
            /* SET EXTERNAL LABELS */
            setFrameLabels(frame b:handle).
            display
               qo_nbr
               qo_cust
               name
               qo_ship
               qo_slspsn[1]
               qo_curr
               qo_ord_date
               qo_flw_date
               qo_exp_date
               qo_recur
               qo_cycle
               qo_stat
               qo_release
            with frame b down width 132 no-attr-space STREAM-IO /*GUI*/ .
         end. /* DO WITH */

         if    o_disp_line1 <> ""
            or qo_slspsn[2] >  ""
         then
            put qo_slspsn[2] at 57  o_disp_line1 at 66.

         if    o_disp_line2 <> ""
            or qo_slspsn[3]  > ""
         then
            put qo_slspsn[3] at 57  o_disp_line2 at 66.

         if qo_slspsn[4] > ""
         then
            put qo_slspsn[4] at 57.

         if qo_rmks <> ""
         then
            put qo_rmks at 13.

         /* GET QUOTE DETAIL  */
         for each qod_det
            fields(qod_desc qod_line qod_nbr qod_part qod_price qod_qty_quot
                   qod_qty_rel       qod_rel_chg      qod_type  qod_um)
            where qod_nbr = qo_nbr
         no-lock by qod_nbr by qod_line with frame c down:
            disp_curr = "".
            /* CONVERT CURRENCY TO BASE IF APPROPRIATE.             */
            if     base_curr <> qo_curr
               and base_rpt  <> qo_curr
            then
               disp_curr = getTermLabel("YES",1).

            /* CONVERT FROM FOREIGN TO BASE CURRENCY */
            {gprunp.i "mcpl" "p" "mc-curr-conv"
               "(input qo_curr,
                 input base_curr,
                 input qo_ex_rate,
                 input qo_ex_rate2,
                 input qod_price,
                 input true, /* ROUND */
                 output base_price,
                 output mc-error-number)"}.

            assign
               curr_price = qod_price
               ext_price  = qod_rel_chg * curr_price.

            /* CONVERT FROM FOREIGN TO BASE CURRENCY */
            {gprunp.i "mcpl" "p" "mc-curr-conv"
               "(input qo_curr,
                 input base_curr,
                 input qo_ex_rate,
                 input qo_ex_rate2,
                 input ext_price,
                 input false, /* DO NOT ROUND */
                 output base_tot,
                 output mc-error-number)"}.

            /* SAVE EXT_PRICE AND BASE_TOT UNROUNDED AMOUNTS */
            assign
               ext_price_unrnd = ext_price
               base_tot_unrnd  = base_tot.

            /* ROUND BASE_TOT PER BASE CURRENCY ROUND METHOD */
            {gprunp.i "mcpl" "p" "mc-curr-rnd"
               "(input-output base_tot,
                 input rndmthd,
                 output mc-error-number)"}
            if mc-error-number <> 0
            then do:
               {pxmsg.i &MSGNUM=mc-error-number &ERRORLEVEL=2}
               leave.
            end. /* IF mc-error-number <> 0 */

            /* ROUND EXT_PRICE PER DOC CURRENCY ROUND METHOD */
            {gprunp.i "mcpl" "p" "mc-curr-rnd"
               "(input-output ext_price,
                 input rndmthd,
                 output mc-error-number)"}
            if mc-error-number <> 0
            then do:
               {pxmsg.i &MSGNUM=mc-error-number &ERRORLEVEL=2}
               leave.
            end. /* IF mc-error-number <> 0 */

            if base_rpt = ""
               and mixed_rpt
            then
               disp_curr = "".

            desc1 = "".
            for first pt_mstr
               fields(pt_desc1 pt_desc2 pt_part)
               where pt_part = qod_part
            no-lock:
            end. /* FOR FIRST pt_mstr */
            if available pt_mstr
            then
               desc1 = pt_desc1 + " " + pt_desc2.
            else
               desc1 = qod_desc.

            if    desc1                    <> ""
               and page-size - line-counter < 2
            then
               page.

            if not (base_rpt = "" and mixed_rpt = no)
            then do:
               display
                  space(3) qod_line qod_part qod_um
                  qod_qty_quot qod_qty_rel qod_rel_chg disp_curr
                  curr_price ext_price qo_rel_date qod_type WITH STREAM-IO /*GUI*/ .
               down 1.

               if desc1 <> ""
               then
                  put desc1 at 8.
            end. /* IF NOT (base_rpt = "" ... */
            else do:
               display
                  space(3) qod_line qod_part qod_um
                  qod_qty_quot qod_qty_rel qod_rel_chg disp_curr
                  base_price @ curr_price base_tot @ ext_price
                  qo_rel_date qod_type WITH STREAM-IO /*GUI*/ .
               down 1.

               if desc1 <> ""
               then
                  put desc1 at 8.
            end. /* ELSE DO */

            accumulate (ext_price) (total).
            accumulate (base_tot) (total).
            accumulate (ext_price_unrnd) (total).
            accumulate (base_tot_unrnd) (total).

            
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/

         end.  /* FOR EACH QOD_DET */

         /*  STORE SALES ORDER TOTALS, BY CURRENCY, IN WORK FILE.    */
         if base_rpt = ""
            and mixed_rpt
         then do:
            find first order_wkfl where qo_curr = ordwk_curr
            exclusive-lock no-error.
            /* IF A RECORD FOR THIS CURRENCY DOESN'T EXIST, */
            if not available order_wkfl
            then do:
               create order_wkfl.
               ordwk_curr = qo_curr.
            end. /* IF NOT AVAILABLE order_wkfl */

            /* ACCUMULATE INDIVIDUAL CURRENCY TOTALS IN WORK FILE. */
            ordwk_for = ordwk_for + (accum total ext_price_unrnd).
            if base_curr <> qo_curr
            then
               ordwk_base = ordwk_base + (accum total base_tot_unrnd).
            else
               ordwk_base = ordwk_for.
         end. /* IF base_rpt = "" */

         /*  DISPLAY SALES ORDER TOTAL.      */
         if (accum total ext_price) <> 0
         then do:
            if page-size - line-counter < 2
            then
               page.
            underline       ext_price.
            /* DISPLAY CURRENCY TOTAL */
            if not (base_rpt = "" and mixed_rpt = no)
            then do:
               down 1 .
               display
                  qo_curr + " " +
                     getTermLabel("ORDER_TOTAL",16) + ":" format "x(17)"
                     @ qod_part
                  accum total (ext_price) @ ext_price
               with frame c STREAM-IO /*GUI*/ .
            end. /* IF NOT base_rpt = "" */
            /*DISPLAY BASE TOTAL */
            if (base_curr <> qo_curr
               and base_rpt = ""
               and mixed_rpt)
               or (base_rpt = ""
               and mixed_rpt = no)
            then do:
               down 1.
               display
                  getTermLabel("BASE_TOTAL",16) + ":" format "x(17)" @ qod_part
                  accum total (base_tot) @ ext_price WITH STREAM-IO /*GUI*/ .
            end. /* IF (base_curr <> qo_curr */
         end. /* if (accum total ext_price) <> 0 then do: */
         
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/

      end. /* FOR EACH qo_mstr */
      down 1.

      /*  DISPLAY REPORT TOTAL            */
      if (page-size - line-counter < 2) and base_rpt <> ""
      then
         page.

      underline        ext_price with frame c.
      display
         base_curr + " " + getTermLabel("REPORT_TOTAL",16) + ":" format "x(17)"
            @ qod_part
         accum total (base_tot) @ ext_price
      with frame c STREAM-IO /*GUI*/ .

      /* IF ALL CURRENCIES, PRINT A SUMMARY REPORT BROKEN BY CURRENCY.*/
      if base_rpt = ""
         and mixed_rpt
      then
         {gprun.i ""gpcurrp.p""}.
   end. /* DO WITH FRAME C */
   /* REPORT TRAILER */
   
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


end. /* REPEAT */

{wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" nbr nbr1 cust cust1 slspsn slspsn1 ord ord1 expdate expdate1 flwdate flwdate1 cycle cycle1 release_only base_rpt mixed_rpt "} /*Drive the Report*/
